<?php


abstract class BaseSmsOutput extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $service_number;


	
	protected $sms_id;


	
	protected $receive_phone;


	
	protected $send_datetime;


	
	protected $sms_type;


	
	protected $content;


	
	protected $description;


	
	protected $charge;


	
	protected $service_name;


	
	protected $status;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getServiceNumber()
	{

		return $this->service_number;
	}

	
	public function getSmsId()
	{

		return $this->sms_id;
	}

	
	public function getReceivePhone()
	{

		return $this->receive_phone;
	}

	
	public function getSendDatetime($format = 'Y-m-d H:i:s')
	{

		if ($this->send_datetime === null || $this->send_datetime === '') {
			return null;
		} elseif (!is_int($this->send_datetime)) {
						$ts = strtotime($this->send_datetime);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [send_datetime] as date/time value: " . var_export($this->send_datetime, true));
			}
		} else {
			$ts = $this->send_datetime;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getSmsType()
	{

		return $this->sms_type;
	}

	
	public function getContent()
	{

		return $this->content;
	}

	
	public function getDescription()
	{

		return $this->description;
	}

	
	public function getCharge()
	{

		return $this->charge;
	}

	
	public function getServiceName()
	{

		return $this->service_name;
	}

	
	public function getStatus()
	{

		return $this->status;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = SmsOutputPeer::ID;
		}

	} 
	
	public function setServiceNumber($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->service_number !== $v) {
			$this->service_number = $v;
			$this->modifiedColumns[] = SmsOutputPeer::SERVICE_NUMBER;
		}

	} 
	
	public function setSmsId($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->sms_id !== $v) {
			$this->sms_id = $v;
			$this->modifiedColumns[] = SmsOutputPeer::SMS_ID;
		}

	} 
	
	public function setReceivePhone($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->receive_phone !== $v) {
			$this->receive_phone = $v;
			$this->modifiedColumns[] = SmsOutputPeer::RECEIVE_PHONE;
		}

	} 
	
	public function setSendDatetime($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [send_datetime] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->send_datetime !== $ts) {
			$this->send_datetime = $ts;
			$this->modifiedColumns[] = SmsOutputPeer::SEND_DATETIME;
		}

	} 
	
	public function setSmsType($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->sms_type !== $v) {
			$this->sms_type = $v;
			$this->modifiedColumns[] = SmsOutputPeer::SMS_TYPE;
		}

	} 
	
	public function setContent($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->content !== $v) {
			$this->content = $v;
			$this->modifiedColumns[] = SmsOutputPeer::CONTENT;
		}

	} 
	
	public function setDescription($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->description !== $v) {
			$this->description = $v;
			$this->modifiedColumns[] = SmsOutputPeer::DESCRIPTION;
		}

	} 
	
	public function setCharge($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->charge !== $v) {
			$this->charge = $v;
			$this->modifiedColumns[] = SmsOutputPeer::CHARGE;
		}

	} 
	
	public function setServiceName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->service_name !== $v) {
			$this->service_name = $v;
			$this->modifiedColumns[] = SmsOutputPeer::SERVICE_NAME;
		}

	} 
	
	public function setStatus($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->status !== $v) {
			$this->status = $v;
			$this->modifiedColumns[] = SmsOutputPeer::STATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->service_number = $rs->getString($startcol + 1);

			$this->sms_id = $rs->getString($startcol + 2);

			$this->receive_phone = $rs->getString($startcol + 3);

			$this->send_datetime = $rs->getTimestamp($startcol + 4, null);

			$this->sms_type = $rs->getInt($startcol + 5);

			$this->content = $rs->getString($startcol + 6);

			$this->description = $rs->getString($startcol + 7);

			$this->charge = $rs->getInt($startcol + 8);

			$this->service_name = $rs->getString($startcol + 9);

			$this->status = $rs->getString($startcol + 10);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 11; 
		} catch (Exception $e) {
			throw new PropelException("Error populating SmsOutput object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SmsOutputPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			SmsOutputPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SmsOutputPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = SmsOutputPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += SmsOutputPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = SmsOutputPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SmsOutputPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getServiceNumber();
				break;
			case 2:
				return $this->getSmsId();
				break;
			case 3:
				return $this->getReceivePhone();
				break;
			case 4:
				return $this->getSendDatetime();
				break;
			case 5:
				return $this->getSmsType();
				break;
			case 6:
				return $this->getContent();
				break;
			case 7:
				return $this->getDescription();
				break;
			case 8:
				return $this->getCharge();
				break;
			case 9:
				return $this->getServiceName();
				break;
			case 10:
				return $this->getStatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SmsOutputPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getServiceNumber(),
			$keys[2] => $this->getSmsId(),
			$keys[3] => $this->getReceivePhone(),
			$keys[4] => $this->getSendDatetime(),
			$keys[5] => $this->getSmsType(),
			$keys[6] => $this->getContent(),
			$keys[7] => $this->getDescription(),
			$keys[8] => $this->getCharge(),
			$keys[9] => $this->getServiceName(),
			$keys[10] => $this->getStatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SmsOutputPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setServiceNumber($value);
				break;
			case 2:
				$this->setSmsId($value);
				break;
			case 3:
				$this->setReceivePhone($value);
				break;
			case 4:
				$this->setSendDatetime($value);
				break;
			case 5:
				$this->setSmsType($value);
				break;
			case 6:
				$this->setContent($value);
				break;
			case 7:
				$this->setDescription($value);
				break;
			case 8:
				$this->setCharge($value);
				break;
			case 9:
				$this->setServiceName($value);
				break;
			case 10:
				$this->setStatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SmsOutputPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setServiceNumber($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setSmsId($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setReceivePhone($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setSendDatetime($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setSmsType($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setContent($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setDescription($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCharge($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setServiceName($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setStatus($arr[$keys[10]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(SmsOutputPeer::DATABASE_NAME);

		if ($this->isColumnModified(SmsOutputPeer::ID)) $criteria->add(SmsOutputPeer::ID, $this->id);
		if ($this->isColumnModified(SmsOutputPeer::SERVICE_NUMBER)) $criteria->add(SmsOutputPeer::SERVICE_NUMBER, $this->service_number);
		if ($this->isColumnModified(SmsOutputPeer::SMS_ID)) $criteria->add(SmsOutputPeer::SMS_ID, $this->sms_id);
		if ($this->isColumnModified(SmsOutputPeer::RECEIVE_PHONE)) $criteria->add(SmsOutputPeer::RECEIVE_PHONE, $this->receive_phone);
		if ($this->isColumnModified(SmsOutputPeer::SEND_DATETIME)) $criteria->add(SmsOutputPeer::SEND_DATETIME, $this->send_datetime);
		if ($this->isColumnModified(SmsOutputPeer::SMS_TYPE)) $criteria->add(SmsOutputPeer::SMS_TYPE, $this->sms_type);
		if ($this->isColumnModified(SmsOutputPeer::CONTENT)) $criteria->add(SmsOutputPeer::CONTENT, $this->content);
		if ($this->isColumnModified(SmsOutputPeer::DESCRIPTION)) $criteria->add(SmsOutputPeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(SmsOutputPeer::CHARGE)) $criteria->add(SmsOutputPeer::CHARGE, $this->charge);
		if ($this->isColumnModified(SmsOutputPeer::SERVICE_NAME)) $criteria->add(SmsOutputPeer::SERVICE_NAME, $this->service_name);
		if ($this->isColumnModified(SmsOutputPeer::STATUS)) $criteria->add(SmsOutputPeer::STATUS, $this->status);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(SmsOutputPeer::DATABASE_NAME);

		$criteria->add(SmsOutputPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setServiceNumber($this->service_number);

		$copyObj->setSmsId($this->sms_id);

		$copyObj->setReceivePhone($this->receive_phone);

		$copyObj->setSendDatetime($this->send_datetime);

		$copyObj->setSmsType($this->sms_type);

		$copyObj->setContent($this->content);

		$copyObj->setDescription($this->description);

		$copyObj->setCharge($this->charge);

		$copyObj->setServiceName($this->service_name);

		$copyObj->setStatus($this->status);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new SmsOutputPeer();
		}
		return self::$peer;
	}

} 